package com.soup.lab.spring.aop.order;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class Aspect2 implements Ordered {

    @Before("com.soup.lab.spring.aop.CommonPointcuts.sampleTest()")
    public void beforeTest() {
        System.out.println("before test Aspect2");
    }

    @After("com.soup.lab.spring.aop.CommonPointcuts.sampleTest()")
    public void afterTest() {
        System.out.println("after test Aspect2");
    }

    @Around("com.soup.lab.spring.aop.CommonPointcuts.sampleTest()")
    public Object aroundTest(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("around before test Aspect2");
        Object proceed = joinPoint.proceed();
        System.out.println("around after test Aspect2");
        return proceed;
    }

    @AfterReturning("com.soup.lab.spring.aop.CommonPointcuts.sampleTest()")
    public void afterReturningTest() {
        System.out.println("after returning test Aspect2");
    }


    @Override
    public int getOrder() {
        return 2;
    }
}
